package org.sunrise.game.rpc.node;

import org.sunrise.game.center.client.ReportClientMessageManager;
import org.sunrise.game.center.message.ReportMessage;
import org.sunrise.game.center.server.NodeManager;
import org.sunrise.game.common.log.LogCore;
import org.sunrise.game.common.message.MessageUtils;

/**
 * rpc上报客户端消息管理器
 * 收到中心服发来的其他节点信息，进行连接
 */
public class RpcNodeReportMessageManager extends ReportClientMessageManager {
    public RpcNodeReportMessageManager(String nodeId) {
        super(nodeId);
    }

    @Override
    protected void pulseHandlerOne(Object data) {
        var message = MessageUtils.fromMessage((byte[]) data, ReportMessage.class);
        if (message.getType() == NodeManager.NODE_TYPE_RPC_NODE) {
            RpcNodeManager.getRpcNode().connectOther(message);
        }
//        LogCore.RpcClient.debug("recv msg, cur NodeId = { {} }, from NodeId = { {} }, messageId = { {} }, data = { {} }", getNodeId(), message.getNodeId(), message.getMessageId(), message);
    }
}
